﻿#include "TcpCodec_User.h"

#include "TcpCodec.h"
#include "Device.h"
#include "UserInfoCodec.h"

TcpCodec_User::TcpCodec_User()
{
  setObjectName(getClassNameFirstLow<TcpCodec_User>());
}

TcpCodec_User::~TcpCodec_User()
{}

void TcpCodec_User::decode(DataPackage_TcpCodec* dataPackageInfo_User)
{
  userInfoCodec->decode(dataPackageInfo_User->getData());
}

TcpCodec* TcpCodec_User::getTcpCodec()const
{
  return tcpCodec;
}

TcpCodec_User* TcpCodec_User::setTcpCodec(TcpCodec* const tcpCodec)
{
  this->tcpCodec=tcpCodec;
  tcpCodec->addToCodecMap(TcpCodec_User::User,this);
  printInjection(this,tcpCodec);
  return this;
}

UserInfoCodec* TcpCodec_User::getUserInfoCodec()const
{
  return userInfoCodec;
}

TcpCodec_User* TcpCodec_User::setUserInfoCodec(UserInfoCodec* const userInfoCodec)
{
  this->userInfoCodec=userInfoCodec;
  printInjection(this,userInfoCodec);
  return this;
}

void TcpCodec_User::objectAutoInjection(QHash<QString,QObject*>* objMap)
{
  setTcpCodec(getObjFromMap<TcpCodec>(objMap));
  setUserInfoCodec(getObjFromMap<UserInfoCodec>(objMap));
}
